<template>
	<view class="page">
		<!-- 头部背景 -->
		<view class="head-bg">
			<view class="integral-balance" v-for="(item,index) in gets" :key="index">
				<view class="integral">
					<text>当前可用积分</text>
					<text class="number">{{item.PointsBalance}}</text>
				</view>
			</view>
			<view class="bg">
				<image src="/static/integral_bg1.png" mode=""></image>
			</view>
		</view>
		<!-- 记录列表 -->
		<view class="record-list">
			<view class="list"  v-for="(item,index) in list" :key="index">
				<view class="title-date">
					<view class="title">
						<text>{{item.Describe}}</text>
					</view>
					<view class="date">
						<text>{{item.CreateTime}}</text>
					</view>
				</view>
				<view class="integral">
					<text>{{item.IntegralNumber}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import integral from '../api/integral';
	export default {
		data() {
			return {
				list:[],
				gets:[],
			};
		},
		onLoad() {
			this.getIntegralList()
			this.getIntegralGet()
		},
		methods:{
			getIntegralList() {
				integral.integralList({
					userId:1,
				}).then(res => {
					console.log(res)
					if (!res.data) {
						console.log('未获取到积分记录');
						return
					}
					this.list = this.list.concat(res.data)
				})
			},
			getIntegralGet() {
			    integral.integralGet({
			        userId: 1,
			    }).then(res => {
			        console.log(res)
			        if (!res.data) {
			            console.log('未获取到可用积分');
			            return
			        }
			        this.gets = this.gets.concat(res.data)
			    })
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'ExchangeRecord.scss';
</style>
